<template>
  <div class="flex-col">
    <div class="new-chat" @click="selectFunction(0)">
      <i class="fa-solid fa-magnifying-glass"></i>
      <span class="new-chat-title" >新项目</span>
    </div>
    <div class="function-list">
      <div class="function-item" 
           v-for="(func, index) in functions" 
           :key="index"
           :class="{ active: activeFunction === func.id }"
           @click="selectFunction(func.id)">
        <i :class="func.icon"></i>
        <span class="function-title">{{ func.name }}</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'ChatList',
  data() {
    return {
      functions: [
        { id: '1', name: '功能点度量', icon: 'fa-solid fa-calculator' },
        { id: '2', name: 'CK度量', icon: 'fa-solid fa-code' },
        { id: '3', name: 'LK度量', icon: 'fa-solid fa-diagram-project' },
        { id: '4', name: '用例图度量', icon: 'fa-solid fa-diagram-next' }
      ],
      activeFunction: null
    }
  },
  methods: {
    createNewChat() {
      this.$emit('create-new-chat');
    },
    selectFunction(funcId) {
      this.activeFunction = funcId;
      this.$emit('function-selected', funcId);
    }
  }
}
</script>

<style scoped>
.flex-col {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  max-height: 100%;
  max-width: 250px;
  overflow-y: auto;
  overflow-x: visible;
  background-color: #ffffff;
}

.new-chat {
  padding: 10px;
  height: 40px;
  display: flex;
  align-items: center;
  border-radius: 10px;
  color: #333333;
  margin: 10px 0;
  cursor: pointer;
  transition: background-color 0.3s;
}

.new-chat:hover {
  background-color: #ecf5ff;
}

.fa-magnifying-glass {
  font-size: 20px;
  padding-left: 8px;
  color: #409eff;
}

.new-chat-title {
  flex: 1;
  padding-left: 10px;
  font-weight: bold;
}

.function-list {
  display: flex;
  flex-direction: column;
  padding: 10px;
}

.function-item {
  padding: 12px;
  margin: 5px 0;
  height: 40px;
  display: flex;
  align-items: center;
  border-radius: 10px;
  color: #333333;
  cursor: pointer;
  transition: all 0.3s;
}

.function-item:hover {
  background-color: #ecf5ff;
}

.function-item.active {
  background-color: #ecf5ff;
  border-left: 3px solid #409eff;
}

.function-item i {
  font-size: 18px;
  padding-left: 8px;
  color: #409eff;
  width: 30px;
}

.function-title {
  flex: 1;
  padding-left: 10px;
  font-size: 14px;
}

::-webkit-scrollbar {
  width: 5px;
  background-color: #f5f7fa;
}

::-webkit-scrollbar-thumb {
  border-radius: 10px;
  background-color: #409eff;
}
</style> 